Skip to content

Workaround a memory corruption issue on Windows Ruby 3.3#9420

Merged
hsbt merged 1 commit into
ruby:masterfrom
Shopify:ec-memory-corruption
Mar 25, 2026
Merged

Workaround a memory corruption issue on Windows Ruby 3.3#9420
hsbt merged 1 commit into
ruby:masterfrom
Shopify:ec-memory-corruption

Conversation

@Edouard-chin

Copy link
Copy Markdown
Member

Warning

Disclaimer: I honestly wasn't able to understand the problem and why this solution works. I don't have a windows machine and relying on CI machines is a bit painful.

What was the end-user or developer problem that led to this PR?

When introducing #9414, master CI started to fail only on windows 3.3. I confirmed that running the failing spec in isolation multiple times reproduce the problem consistently.

What is your fix for the problem, implemented in this PR?

The error being either a segfault or a Bundler error along the line of "Illformed requirement ~> false.1.3.pre".

I triggered some CI with debugging output and the corruption seem to happen when version.release is called. It somehow modifies the previously defined variable segments (it's not a mutation).

This is the debugging output I added Shopify@6a147a0 and the associated CI run is at https://github.com/Shopify/rubygems/actions/runs/23465022092/job/68275229509#step:7:177

Pasting here in case the CI log get cleared:

segments variable is [0, 12, 3, "pre"]. Object ID is 25820
version.segments is [0, 12, 3, "pre"].
======== AFTER ========
Segments is [-1, 12, 3, "pre"]. Object ID is 25820
version.segments is [0, 12, 3, "pre"].

In this patch, I opted to reference the version.segments object directly, again, I don't know why it fixes the issue.

Make sure the following tasks are checked

cc @hsbt Feel free to close this one as I understand that Ruby 3.3 is on security maintenance only. I figured it could prevent users on 3.3 from not being able to use Bundler as I suspect they will encounter this problem. Though, sorry that I'm not able to provide a concrete explanation as to why this happens. Computers ... 😮‍💨

- Disclaimer: I honestly wasn't able to understand the problem and why
  this solution works. I don't have a windows machine and relying on
  CI machines is a bit painful.

  When introducing ruby#9414,
  master CI started to fail only on windows 3.3.
  I confirmed that running the failing spec in isolation multiple
  times reproduce the problem consistently.

  The error being either a segfault or a Bundler error along the line
  of "Illformed requirement `~> false.1.3.pre`".

  I triggered some CI with debugging output and the corruption
  seem to happen when `version.release` is called. It somehow
  modifies the previously defined variable `segments` (it's not
  a mutation).

  This is the debugging output I added 6a147a0
  and the associated CI run is at https://github.com/Shopify/rubygems/actions/runs/23465022092/job/68275229509#step:7:177

  Pasting here in case the CI log get cleared:

  ```
    segments variable is [0, 12, 3, "pre"]. Object ID is 25820
    version.segments is [0, 12, 3, "pre"].
    ========
    AFTER
    ========
    Segments is [-1, 12, 3, "pre"]. Object ID is 25820
    version.segments is [0, 12, 3, "pre"].
  ```

  In this patch, I opted to reference the `version.segments` object
  directly, again, I don't know why it fixes the issue.
@hsbt

hsbt commented Mar 25, 2026

Copy link
Copy Markdown
Member

🙏 Thanks! It seems the tests passed, so I'll merge it and try it out in the next release.

@hsbt hsbt merged commit f1cf945 into ruby:master Mar 25, 2026
95 checks passed
hsbt added a commit that referenced this pull request Apr 7, 2026
Workaround a memory corruption issue on Windows Ruby 3.3

(cherry picked from commit f1cf945)
hsbt added a commit that referenced this pull request Apr 7, 2026
Workaround a memory corruption issue on Windows Ruby 3.3

(cherry picked from commit f1cf945)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants